(define (test func cases run)
  (define (run-it case)
    (let ((input (car case))
          (want (cadr case)))
      (run func input want)))
  (cond ((null? cases) 'end)
        (else 
         (run-it (car cases))
         (test func (cdr cases) run))))
(define test-result (cons 0 0)) ; ok total
(define (run func input want)
  (display "test" func)
  (set-cdr! test-result (+ 1 (cdr test-result)))
  (let ((got (apply func input)))
    (cond ((not (equal? got want))
           (display func "fail, want" want "got" got)
           0)
          (else 
           (set-car! test-result (+ 1 (car test-result)))
           1))))

; test cases
(define (add a b) (+ a b))
(test accumulate 
      (list
       (list (list add 0 '(1 2 3 4)) 10)
       )
      run)

(display (car test-result) "/" (cdr test-result))
(if (= (car test-result) (cdr test-result))
    (display "OK")
    (display "FAIL!"))